<?php
# MantisBT - a php based bugtracking system

# MantisBT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# MantisBT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MantisBT.  If not, see <http://www.gnu.org/licenses/>.

	/**
	 * @package MantisBT
	 * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
	 * @copyright Copyright (C) 2002 - 2010  MantisBT Team - mantisbt-dev@lists.sourceforge.net
	 * @link http://www.mantisbt.org
	 */
	 /**
	  * MantisBT Core API's
	  */
	require_once( 'core.php' );
	require_once( 'current_user_api.php' );
	require_once( 'compress_api.php' );
	require_once( 'filter_api.php' );
	require_once( 'last_visited_api.php' );

	auth_ensure_user_authenticated();

	$t_current_user_name = current_user_get_field( 'username' );
	$t_current_real_name = current_user_get_field( 'realname' );
	$t_current_al = current_user_get_field( 'access_level' );
	
	# Improve performance by caching category data in one pass
	category_get_all_rows( helper_get_current_project() );

	compress_enable();

	# don't index my view page
	html_robots_noindex();

	html_page_top1( lang_get( 'my_view_link' ) );

	if ( current_user_get_pref( 'refresh_delay' ) > 0 ) {
		html_meta_redirect( 'my_view_page.php', current_user_get_pref( 'refresh_delay' )*60 );
	}

	html_page_top2();

	print_recently_visited();

	$f_page_number		= gpc_get_int( 'page_number', 1 );

	$t_per_page = config_get( 'my_view_bug_count' );
	$t_bug_count = null;
	$t_page_count = null;

	$t_boxes = config_get( 'my_view_boxes' );
	asort ($t_boxes);
	reset ($t_boxes);
	#print_r ($t_boxes);

	$t_project_id = helper_get_current_project();

if ($t_current_al >= 40) {
?>
<br>
Trung tâm kinh doanh Dự án<br>
================================================================================================
<table border=0 cellspacing="3" cellpadding="0" width=100%>
			<tr>
				<td align="center">[<a href="?do=addcare">Add care</a>] | [<a href="?do=viewall">View all</a>] | [<a href="?do=creport">Xuất báo cáo</a>] | [<a href="coogle.php">Search</a>] 
				</td>
			</tr>
</table>

<div align="center">
<table border=0 cellspacing="3" cellpadding="0" width=100%>
			<tr>
				<td>
				<?php 

				$do = $_GET['do'];
				
//Add thông tin khách hàng
		if ($do == addcare)
				{			
							echo '
							 <html xmlns="http://www.w3.org/1999/xhtml">
					<head>
					<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
					<title>Seller management Systems</title>
					<link rel="stylesheet" href="css/style.css" type="text/css">
					<title>Nhập contact khách hàng</title> 
					<style> 
					fieldset{display: none; padding: 10px;} 
					</style> 
					<script type="text/javascript"> 
					function toggleSet(rad) 
					{ 
					  var type = rad.value; 
					  for(var k=0,elm;elm=rad.form.elements[k];k++) 
						if(elm.className=="item") 
						  elm.style.display = elm.id==type? "inline":""; 
					} 
					</script> 
					</head>
					<body>		
						<form name="care" action="?do=pdata" method="post">
						<table border=1 cellpadding=0 cellspacing=0 style="border-collapse:collapse" width=60%>
						<tr><td bgcolor=green>
						<font color=white><b>Thông tin khách hàng</b></font>
						</td></tr>
						<tr><td>
						<table border=0>
							<tr><td>Tên doanh nghiệp </td><td><input name="ctname" type="ctname"></td><td>SDT liên lạc :</td><td><input name="ctphone" type="ctphone"></td></tr>
							<tr><td>Mã số thuế </td><td><input name="ctmst" type="ctmst"></td><td>Số TK ngân hàng :</td><td><input name="ctbank" type="ctbank"></td></tr>
							<tr><td>Địa chỉ :</td><td><input name="ctaddress" type="ctaddress"><br></td>
							<td>Tỉnh/TP : </td><td><Select name="city">
									<option value =default>Chưa xác định</option>
									<option value =angiang>An Giang</option>
									<option value =brvt>Bà rịa vũng tàu</option>
									<option value =bacgiang>Bắc Giang</option>
									<option value =baclieu>bạc liêu</option>
									<option value =baccan>bắc cạn</option>
									<option value =bacninh>bắc ninh</option>
									<option value =bentre>bến tre</option>
									<option value =binhdinh>bình định</option>
									<option value =binhduong>bình dương</option>
									<option value =binhphuoc>bình phước</option>
									<option value =binhthuan>bình thuận</option>
									<option value =camau>cà mau</option>
									<option value =caobang>cao bằng</option>
									<option value =cantho>cần thơ</option>
									<option value =danang>đà nẵng</option>
									<option value =dl>đắk lắk</option>
									<option value =dn>đắk nông</option>
									<option value =dienbien>điện biên</option>
									<option value =dongnai>đồng nai</option>
									<option value =dongthap>đồng tháp</option>
									<option value =gialai>gia lai</option>
									<option value =hagiang>hà giang</option>
									<option value =hanam>hà nam</option>
									<option value =hanoi>hà nội</option>
									<option value =hatinh>hà tĩnh</option>
									<option value =haiduong>hải dương</option>
									<option value =haiphong>hải phòng</option>
									<option value =haugiang>hậu giang</option>
									<option value =hoabinh>hòa bình</option>
									<option value =hcm>hcm</option>
									<option value =hungyen>hưng yên</option>
									<option value =khanhhoa>khánh hòa</option>
									<option value =kiengiang>kiên giang</option>
									<option value =kontum>kon tum</option>
									<option value =laichau>lai châu</option>
									<option value =lamdong>lam dong</option>
									<option value =langson>lạng sơn</option>
									<option value =laocai>lào cai</option>
									<option value =longan>long an</option>
									<option value =namdinh>nam định</option>
									<option value =nghean>nghệ an</option>
									<option value =ninhbinh>ninh bình</option>
									<option value =ninhthuan>ninh thuận</option>
									<option value =phutho>phú thọ</option>
									<option value =phuyen>phú yên</option>
									<option value =quangbinh>quảng bình</option>
									<option value =quangnam>quảng nam</option>
									<option value =quangngai>quảng ngãi</option>
									<option value =quangninh>quảng ninh</option>
									<option value =quangtri>quảng trị</option>
									<option value =soctrang>sóc trăng</option>
									<option value =sonla>sơn la</option>
									<option value =tayninh>tây ninh</option>
									<option value =thaibinh>thái bình</option>
									<option value =thainguyen>thái nguyên</option>
									<option value =thanhhoa>thanh hóa</option>
									<option value =thuathienhue>thừa thiên huế</option>
									<option value =tiengiang>tiền giang</option>
									<option value =travinh>trà vinh</option>
									<option value =tuyenquang>tuyên quang</option>
									<option value =vinhlong>vĩnh long</option>
									<option value =vinhphuc>vĩnh phúc</option>
									<option value =yenbai>yên bái</option>	
								</select><br></td></tr>
							<tr>
							<td> Đối tượng: </td><td><Select name="area">
								<option value =mienbac>Dự án Miền Bắc</option>
								<option value =mientrung>Dự án Miền Trung</option>
								<option value =miennam>Dự án Miền Nam</option>
								</select><br></td>
								
								<td> Phân khúc thị trường </td><td><Select name="cpk">
								<option value =bank>Ngân hàng/ Chứng khoán/ Bảo hiểm</option>
								<option value =nntw>Khối Nhà Nước TW</option>
								<option value =nnt>Khối Nhà Nước Tỉnh</option>
								<option value =anninh>Khối An Ninh - Quốc Phòng</option>
								<option value =yte>Khối Y Tế</option>
								<option value =congnghiep>Khối Công nghiệp/Nhà máy</option>
								<option value =ttdulich>Khối Thông tin/Du lịch/Báo chí</option>
								<option value =cntt>Khối công ty CNNT</option>
								<option value =telco>Khối Telco (Viễn Thông)</option>
								<option value =nangluong>Khối Năng Lượng</option>
								</select><br>
							</td></tr>
							
							<tr>
							<td> Trạng thái khách hàng</td><td><Select name="ctype">
								<option value=kt1>KT1</option>
								<option value=kt2>KT2</option>
								<option value=kt3>KT3</option>
								</select><br>
							</td>
							<td> Project status </td><td><Select name="cstatus">
								<option value=tiepcan>Tiếp cận</option>
								<option value=khaosat>Khảo sát</option>
								<option value=dauthau>Đầu thầu</option>
								<option value=kihopdong>Kí hợp đồng</option>
								<option value=dangtrienkhai>Đang triển khai</option>
								<option value=nghiemthu>Nghiệm thu</option>
								<option value=closedwin>ClosedWin</option>
								<option value=closedlost>ClosedLost</option>
								</select>
							</td>
							</tr>
							
							<tr><td>Đại diện/phụ trách:</td><td><input name="nMan" type="nMan"></td><td>Phone :</td><td><input name="pMan" type="pMan"></td></tr>
							<tr><td>Email :</td><td><input name="eMan" type="eMan"></td></tr><tr>
							<td> Server/client </td><td> 
							<input name="tserver" type="tserver" style="width:30px;"> - <input name="tclient" type="tclient" style="width:30px;">
							</td><td> Doanh số dự án</td><td><input name="cdoanhso" type="text" /></td></tr>
						</td></tr></table>
						</table>
						<br>
						<table border=1 cellpadding=0 cellspacing=0 style="border-collapse:collapse;" width=50%>
						<tr><td bgcolor=green><font color=white><b>Phân tích/đánh giá khách hàng</b></font></td></tr>
						<tr><td>
						<table>
							<tr><td> Assign to </td><td><Select name="assignto">';
								$req = mysql_query("select username from `mantis_user_table` where access_level='40'");
									while ($row = mysql_fetch_array($req)){
									if ($row['username'] != $seller){ 
									echo'<option value ='.$row['username'].'>'.$row['username'].'</option>';}
									}
								echo '</select><br>
								</td></tr>
							<tr>
							<td> Kĩ thuật phụ trách </td><td><Select name="csupport">
								<option value =hungdv>Đào Việt Hùng</option>
								<option value =sonln>Lê Ngọc Sơn</option>
								<option value =hoangth>Trần Huy Hoàng</option>
								</select><br></td></tr>
							<tr><td>Thông tin chính dự án</td><td><textarea name="confirm" type="confirm" cols="44" rows="5"></textarea><br></td></tr>
							<tr><td>Đánh giá/phân tích</td><td><textarea name="process" type="process" cols="44" rows="5"></textarea></tr>
							<tr><td><input name="submit" type="submit" value="submit"></td></tr>
							</table>
							</td></tr></table>
							</form></body></html>';
						}
						
//Ghi dữ liệu khách hàng vào data
		if ($do == pdata)
		{
						echo '<html xmlns="http://www.w3.org/1999/xhtml">
						<head>
						<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
						<title>Seller management Systems</title>
						<link rel="stylesheet" href="css/style.css" type="text/css">
						</head>
						<body>';
						$seller = $t_current_user_name;
						//send information from form
						$ctname = $_POST['ctname'];
						$ctphone = $_POST['ctphone'];
						$ctmst = $_POST['ctmst'];
						$ctbank = $_POST['ctbank'];
						$ctaddress = $_POST['ctaddress'];
						$city = $_POST['city'];
						$area = $_POST['area'];
						
						$nMan = $_POST['nMan'];
						$pMan = $_POST['pMan'];
						$eMan = $_POST['eMan'];
						$ctype = $_POST['ctype'];
						$cdoanhso = $_POST['cdoanhso'];
						$cstatus = $_POST['cstatus'];
						$cpk = $_POST['cpk'];
						
						$tserver = $_POST['tserver'];
						$tclient = $_POST['tclient'];
						
						$assignto = $_POST['assignto'];
						$csupport = $_POST['csupport'];
						$confirm = $_POST['confirm'];
						$process = $_POST['process'];
						
						$time = date("H:i:s, d-m-Y");
						$start_time = time();
						
						if (preg_match('/^\(?[0]{1}[0-9]{2}\)?|[0-9]{3,3}?[ ][0-9]{3,3}?[0-9]{4,4}$/', $ctphone)) 
						
						{ 	/* //Them so vao Serial/Lo
							if(strlen($serial) == 4) {	$serial = '0'.$serial;}
							if(strlen($serial) == 3) {	$serial = '00'.$serial;}
							if(strlen($serial) == 2) {	$serial = '000'.$serial;}
							if(strlen($serial) == 1) {	$serial = '0000'.$serial;} */
							
							echo '<div align=center><table border=1><tr><td align=center>';
							//Insert thong tin cham soc khach hang
							mysql_query("
								insert into `mantis_projectcenter_table` 
								(ctname, ctphone, ctmst, ctbank, ctaddress, city, area, nMan, pMan, eMan, ctype, cdoanhso, cstatus, cpk ,tserver, tclient, assignto, csupport, confirm, process, start_time) 											
								values('$ctname','$ctphone','$ctmst','$ctbank','$ctaddress','$city','$area','$nMan',
								'$pMan','$eMan','$ctype','$cdoanhso','$cstatus','$cpk','$tserver','$tclient',
								'$assignto','$csupport','$confirm','$process','$start_time')");
								echo "Bạn đã nhập dữ liệu khách hàng <b>".$ctname."</b> thành công<br>";
								echo "Check danh sách khách hàng chăm sóc trong ngày hôm nay";
								echo  "<div align=center><br><a href='?do=viewall'>[LIST]</a> | <a href='logout_page.php'>[Logout]</a></div>";
							
							echo '</td></tr></table></div>';	
						}
						else
							{ 
							echo "<div align=left>
							Bạn nhập sai số điện thoại rồi, nhập lại ngay<br>
							<b><u>Chú ý:</u></b><br>
							#Không có dấu cách ở đầu<br>#Không được thiếu đầu 0 ở đầu</div>";
							}
						
		}
			
//Hiện thị toàn bộ danh khách hàng
		if ($do == viewall)
		{	
			$req = mysql_query("select * from `mantis_projectcenter_table` ORDER BY id DESC");
			echo ' <html xmlns="http://www.w3.org/1999/xhtml">
					<head>
					<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
					<title>Seller management Systems</title>
					<link rel="stylesheet" href="css/default.css" type="text/css">
					<title></title> 
					</head>
					<body>	
					<table border=1 cellspacing=0 cellpadding=0 style="border-collapse:collapse" width=100%> 
						<tr>
							<td>
								<table border=1 bordercolor=white cellspacing=0 cellpadding=0 style="border-collapse:collapse" width=100% bgcolor=#CECEFF class=ttt>  
									<tr>
										<td width=2% height=30><b>ID</td>
										<td width=20%><b>TÊN DOANH NGHIỆP</td>
										<td width=7%><b>TRẠNG THÁI</td>
										<td width=5%><b>ASSIGNED TO</td>
										<td width=2%><b>KT</td>
										<td width=15%><b>PHÂN KHÚC THỊ TRƯỜNG</td>
										<td width=3%><b>sTime</td>
										<td width=3%><b>uTime</td>
										<td width=7%><b>HỖ TRỢ CUỐI</td>
									</tr>
								';
							$i = '0';
							$b = 0;
							while ($row = mysql_fetch_array($req))
							{	
									if($b%2==0)  { $sl = '#E1E1E1';}else{ $sl = 'white';}
									$i++;
									$id = $row['id'];
									$ctname = $row['ctname'];
									$ctphone = $row['ctphone'];
									$ctmst = $row['ctmst'];
									$ctbank = $row['ctbank'];
									$ctaddress = $row['ctaddress'];
									$city = $row['city'];
									$area = $row['area'];
									
									$nMan = $row['nMan'];
									$pMan = $row['pMan'];
									$eMan = $row['eMan'];
									$tserver = $row['tserver'];
									$tclient = $row['tclient'];
									
									$cstatus = $row['cstatus'];
									$ctype = $row['ctype'];
									$cpk = $row['cpk'];
									$confirm = $row['confirm'];
									$process = $row['process'];
									$assignto = $row['assignto'];
									$carer = $row['carer'];
									$time = date("H:i:s, d-m-Y");
									$start_time = (date("d/m/Y",$row['start_time']));
									$QueryDay = (date("d",$row['start_time']));
									$QueryCurrentDay = date("d");
									$QueryCurrentMonth = (date("m",$row['start_time']));
									$QueryMonth = date("m");
									include('changeinfo.php');
									
									// Max a last update

									$qr = "SELECT MAX(last_updated),last_updated, pid, note, resolver FROM mantis_project_note_table WHERE pid=$id Group by pid"; 
									$resultt = mysql_query($qr) or die(mysql_error());
												
									$qt = "SELECT MAX(last_updated),last_updated, pid, note, resolver FROM mantis_project_note_table WHERE pid=$id Group by last_updated ORDER BY last_updated DESC LIMIT 0,1"; 
									$resultqt = mysql_query($qt) or die(mysql_error());
									// Print out result
													
									echo '<tr>
										<td bgcolor='.$sl.' height=30><a href="view_care_report.php?do=viewpj&id='.$id.'">'.$i.'</a></td>
										<td bgcolor='.$sl.'>'.$ctname.'</td>
										<td class='.$cls.'><b>'.$ptc.'</td>
										<td bgcolor='.$sl.'>'.$assignto.'</td>
										<td bgcolor='.$sl.'>'.$ctype.'</td>
										<td bgcolor='.$sl.'>'.$rcpk.'</td>
										<td bgcolor='.$sl.'>'.$start_time.'</td>
										<td bgcolor='.$sl.'>';
													while($row = mysql_fetch_array($resultt))
															{
																$pid = $row['pid'];
																$note = $row['note'];
																$resolver = $row['resolver'];
																$last_updated = (date("d/m/Y",$row['MAX(last_updated)']));
																echo $last_updated;
															}	echo '</td>
										<td bgcolor='.$sl.'>';
										while($row = mysql_fetch_array($resultqt))
										{
											$resolver = $row['resolver'];
											echo $resolver;
										}	echo'</td></tr>';					
							}
			echo '	</table><br></td></tr></table>
					</body></html>';
		}
		
//View cac khach hang cua Current user

		if ($do == creport)
		{	
			$er = current_user_get_field( 'access_level' );
			echo '<table border=1>
			<tr><td></td><td><u>Xuất báo cáo theo thời gian chỉ định</u><br><br></td></tr>
			<form name=xreport method=POST action="?do=xreport&value=x">
			<tr><td>Day: </td><td> From <input name=sDay type=sDay> to <input name=eDay type=eDay><br></td></tr>
			<tr><td>Month:</td><td> From <input name=sMonth type=sMonth> to <input name=eMonth type=eMonth>  <br></td></tr>
			<tr><td>Year: </td><td> From <input name=sYear type=sYear> to <input name=eYear type=eYear><br></td></tr>';
			if ($er == 90) { echo '<tr><td>Agent</td><td><input name=cNameAgent type=cNameAgent></td></tr>';}
			echo '<tr><td></td><td><input name=submit type=submit value=submit></td></tr></form></table>';
		}
		
//Xreport
		if (($do == xreport) and ($_GET['value'] == x))
		{
			$sDay = $_POST['sDay'];
			$sMonth = $_POST['sMonth'];
			$sYear = $_POST['sYear'];
			$eDay = $_POST['eDay'];
			$eMonth = $_POST['eMonth'];
			$eYear = $_POST['eYear'];
			$username = $_POST['cNameAgent'];
			echo '<br>
				<input type="button" onClick="window.print()" value="In báo cáo"/>
				<br><br>
				<table border=1 cellspacing=0 cellpadding=0 style="border-collapse:collapse" width=100% > 
						<tr>
							<td>  <b>Viewing all report</b> [ Print Reports ]  [ CSV Export ]  [ Excel Export ]<br><br>    
								<table border=1 bordercolor=black bgcolor=#CECEFF cellspacing=0 cellpadding=0 style="border-collapse:collapse" width=100% bgcolor=#CECEFF class=ttt>  
									<tr>
										<td width=2% ><b>ID</td>
										<td width=2% ><b>PID</td>
										<td width=10%><b>Name</td>
										<td width=10%><b>Category</td>
										<td width=7%><b>Time</td>
										<td width=7%><b>Start supporter</td>
										<td width=20%><b>Phản hồi/Xử lí</td>
									</tr>
								
								';
							$i = 0;
							$er = current_user_get_field( 'access_level' );
							
					if ($er <90)
					{
							$CheckNoteOfMonth = mysql_query("select n.id,n.pid,n.note,n.resolver,n.last_updated,p.id,p.ctname,p.ctphone, 
							p.ctmst,p.ctbank,p.ctaddress,p.city,p.area,p.nMan,p.pMan,p.eMan,p.tserver,
							p.tclient,p.object,p.status,p.state,p.confirm,p.process,p.mark,p.start_time,p.carer
									FROM `mantis_projectcenter_table` AS p,`mantis_project_note_table` AS n
									WHERE 
									from_unixtime(n.last_updated, '%e') >='$sDay' AND from_unixtime(n.last_updated, '%e')<='$eDay'
									AND from_unixtime(n.last_updated, '%c') >='$sMonth' AND from_unixtime(n.last_updated, '%c')<='$eMonth'
									AND from_unixtime(n.last_updated, '%Y') >='$sYear' AND from_unixtime(n.last_updated, '%Y')<='$eYear'
									AND p.id = n.pid
									ORDER By p.id ASC");
							$CheckReportOfMonth = mysql_query("select * from `mantis_projectcenter_table` WHERE carer='$t_current_user_name' 
									AND from_unixtime(start_time, '%e') >='$sDay' AND from_unixtime(start_time, '%e')<='$eDay'
									AND from_unixtime(start_time, '%c') >='$sMonth' AND from_unixtime(start_time, '%c')<='$eMonth'
									AND from_unixtime(start_time, '%Y') >='$sYear' AND from_unixtime(start_time, '%Y')<='$eYear'
									ORDER By id ASC");
					}
					else 
					{		
							$CheckNoteOfMonth = mysql_query("select n.id,n.pid,n.note,n.resolver,n.last_updated,p.id,p.ctname,p.ctphone, 
							p.ctmst,p.ctbank,p.ctaddress,p.city,p.area,p.nMan,p.pMan,p.eMan,p.tserver,
							p.tclient,p.object,p.status,p.state,p.confirm,p.process,p.mark,p.start_time,p.carer
									FROM `mantis_projectcenter_table` AS p,`mantis_project_note_table` AS n
									WHERE 
									from_unixtime(n.last_updated, '%e') >='$sDay' AND from_unixtime(n.last_updated, '%e')<='$eDay'
									AND from_unixtime(n.last_updated, '%c') >='$sMonth' AND from_unixtime(n.last_updated, '%c')<='$eMonth'
									AND from_unixtime(n.last_updated, '%Y') >='$sYear' AND from_unixtime(n.last_updated, '%Y')<='$eYear'
									AND p.id = n.pid
									ORDER By p.id ASC");
							$CheckReportOfMonth = mysql_query("select * from `mantis_projectcenter_table` WHERE carer='$username' 
									AND from_unixtime(start_time, '%e') >='$sDay' AND from_unixtime(start_time, '%e')<='$eDay'
									AND from_unixtime(start_time, '%c') >='$sMonth' AND from_unixtime(start_time, '%c')<='$eMonth'
									AND from_unixtime(start_time, '%Y') >='$sYear' AND from_unixtime(start_time, '%Y')<='$eYear'
									ORDER By id ASC
							");
					}
					//Trich xuat du lieu theo report
					while ($row = mysql_fetch_array($CheckReportOfMonth))
					{
									$i++;
									$id = $row['id'];
									$ctname = $row['ctname'];
									$ctphone = $row['ctphone'];
									$ctmst = $row['ctmst'];
									$ctbank = $row['ctbank'];
									$ctaddress = $row['ctaddress'];
									$city = $row['city'];
									$area = $row['area'];
									$nMan = $row['nMan'];
									$pMan = $row['pMan'];
									$eMan = $row['eMan'];
									$tserver = $row['tserver'];
									$tclient = $row['tclient'];
									
									$object = $row['object'];
									$status = $row['status'];
									$state = $row['itemtype'];
									$confirm = $row['confirm'];
									$process = $row['process'];
									$receiver = $row['receiver'];
									$carer = $row['carer'];
									$time = date("H:i:s, d-m-Y");
									$start_time = (date("d-m-Y H:i:s",$row['start_time']));
									
								echo '<tr>
										<td bgcolor=#E1E1E1>'.$i.'</td>
										<td bgcolor=#E1E1E1><a href="view_care_report.php?do=viewpj&id='.$id.'">'.$id.'</a></td>
										<td bgcolor=#E1E1E1>'.$ctname.'</td>
										<td bgcolor=#E1E1E1>['.$status.'] '.$object.'</td>
										<td bgcolor=#E1E1E1>'.$start_time.'</td>
										<td bgcolor=#E1E1E1>'.$carer.'</td>
										<td bgcolor=#E1E1E1>'.nl2br(substr($confirm,0,300)).'<br><br><u>Xử lí:</u><br>'.nl2br(substr($process,0,300)).'</td>
									</tr>';	
					} 
					// Check note 
					while ($row = mysql_fetch_array($CheckNoteOfMonth))
					{
									$i++;
									$id = $row['id'];
									$pid = $row['pid'];
									$resolver = $row['resolver'];
									$note = $row['note'];
									$ctname = $row['ctname'];
									$last_updated = (date("d-m-Y H:i:s",$row['last_updated']));
									echo '<tr>
										<td bgcolor=#E1E1E1>'.$i.'</td>
										<td bgcolor=#E1E1E1><a href="view_care_report.php?do=viewpj&id='.$pid.'">'.$pid.'</a></td>
										<td bgcolor=#E1E1E1>'.$ctname.'</td>
										<td bgcolor=#E1E1E1>['.$status.'] '.$object.'</td>
										<td bgcolor=#E1E1E1>'.$last_updated.'</td>
										<td bgcolor=#E1E1E1>'.$carer.'</td>
										<td bgcolor=#E1E1E1>'.nl2br(substr($note,0,300)).'</td>
										</tr>';	
					}
				
						echo '</table>';
				echo '<div align=center width=50%>
				<table width=80% height=200 border=1>
				<tr>
					<td width=50% class=sign valign=top><br><br><b>Người báo cáo<br><br><br><br><br><br><br><br><br>'.$t_current_real_name.'</td>
					<td width=50% class=sign valign=top><br><br><b>Người xác nhận<br> GD Trung Tâm DVKH<br><br><br><br><br><br><br><br>Lương Vũ An Bình</td>
				</tr>
				</table>
				</div>';
				
		}
		
//Khu vực download
		if ($do == download){echo 'download';}

}
else { echo "<br><div align=center><b>Bạn không có quyền truy cập vào tài nguyên khu vực này. Liên hệ lãnh đạo để hỏi!</div>";}
		?>
					</td>
			
	</tr>
			</table>
</div>

<?php
	html_page_bottom();
